/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.shopping.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import cn.itlaobing.shopping.model.OrderModel;

/** 
 * ClassName: ShopDao <br/> 
 * Function: 数据访问类<br/> 
 * date: 2017年11月1日 上午9:56:55 <br/> 
 * 
 * @author 王建蕊 
 * @version 1.0 
 * @since JDK 1.8 
 */
public class ShopDao {
	private DBHelper dh=new DBHelper();
	public void close()throws SQLException{
		dh.close();
	}
	public List<OrderModel> query(int uid)throws ClassNotFoundException,SQLException{
		String sql="SELECT os.* FROM orders os INNER JOIN users us ON us.id=os.uid AND os.uid=?";
		List<OrderModel> list=new ArrayList<OrderModel>();
		ResultSet rs=dh.executeQuery(sql,uid);
		while(rs.next()) {
			OrderModel om=new OrderModel();
			om.setId(rs.getInt(1));
			om.setOrderno(rs.getString(2));
			om.setOrdertime(rs.getString(3));
			om.setUid(rs.getInt(4));
			om.setMoney(rs.getInt(5));
			om.setStatu(rs.getInt(6));
			om.setOrderfrom(rs.getString(7));
			om.setConame(rs.getString(8));
			om.setConphone(rs.getString(9));
			om.setConloc(rs.getString(10));
			list.add(om);
			
		}
		return list;
	}
}
